/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ep.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Spyros
 */
@Entity
@Table(name = "t009_medicine", catalog = "epresc", schema = "")
@NamedQueries({
    @NamedQuery(name = "T009Medicine.findAll", query = "SELECT t FROM T009Medicine t"),
    @NamedQuery(name = "T009Medicine.findById", query = "SELECT t FROM T009Medicine t WHERE t.id = :id"),
    @NamedQuery(name = "T009Medicine.findByCode", query = "SELECT t FROM T009Medicine t WHERE t.code = :code"),
    @NamedQuery(name = "T009Medicine.findByName", query = "SELECT t FROM T009Medicine t WHERE t.name = :name"),
    @NamedQuery(name = "T009Medicine.findByPrice", query = "SELECT t FROM T009Medicine t WHERE t.price = :price")})
public class T009Medicine implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "price")
    private Double price;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "t009Medicine", fetch = FetchType.LAZY)
    private Collection<T008Dosage> t008DosageCollection;
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "t009_t010",
    joinColumns =
    @JoinColumn(name = "t009_medicine_id"),
    inverseJoinColumns =
    @JoinColumn(name = "t010_substance_id"))
    private Collection<T010Substance> t010Substances;

    public T009Medicine() {
    }

    public T009Medicine(Integer id) {
        this.id = id;
    }

    public T009Medicine(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Collection<T008Dosage> getT008DosageCollection() {
        return t008DosageCollection;
    }

    public void setT008DosageCollection(Collection<T008Dosage> t008DosageCollection) {
        this.t008DosageCollection = t008DosageCollection;
    }

    public Collection<T010Substance> getT010Substances() {
        return t010Substances;
    }

    public void setT010Substances(Collection<T010Substance> t010Substances) {
        this.t010Substances = t010Substances;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof T009Medicine)) {
            return false;
        }
        T009Medicine other = (T009Medicine) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name;
    }
}
